import java.util.regex.Pattern;
import java.util.regex.Matcher;

public class Main {
    public static String solution(int n, String template, String[] titles) {
        // 将模板中的通配符替换为正则表达式中的任意字符匹配模式
        String pattern = template.replaceAll("\\{.*?\\}", ".*");
        // 编译正则表达式模式
        Pattern regex = Pattern.compile(pattern);

        // 对每个标题进行匹配，并将结果转换为字符串列表
        String[] results = new String[titles.length];
        for (int i = 0; i < titles.length; i++) {
            Matcher matcher = regex.matcher(titles[i]);
            // results[i] = String.valueOf(matcher.matches());
            String boolStr = String.valueOf(matcher.matches());

            results[i] = boolStr.substring(0, 1).toUpperCase() + boolStr.substring(1);
        }
        // 将结果列表用逗号连接成一个字符串
        return String.join(",", results);
    }

    public static void main(String[] args) {
        String[] testTitles1 = {"adcdcefdfeffe", "adcdcefdfeff", "dcdcefdfeffe", "adcdcfe"};
        String[] testTitles2 = {"CLSomGhcQNvFuzENTAMLCqxBdj", "CLSomNvFuXTASzENTAMLCqxBdj",
                              "CLSomFuXTASzExBdj", "CLSoQNvFuMLCqxBdj", "SovFuXTASzENTAMLCq", "mGhcQNvFuXTASzENTAMLCqx"};
        String[] testTitles3 = {"abcdefg", "abefg", "efg"};

        System.out.println(solution(4, "ad{xyz}cdc{y}f{x}e", testTitles1).equalsIgnoreCase("true,false,false,true"));
        System.out.println(solution(6, "{xxx}h{cQ}N{vF}u{XTA}S{NTA}MLCq{yyy}", testTitles2).equalsIgnoreCase("false,false,false,false,false,true"));
        System.out.println(solution(3, "a{bdc}efg", testTitles3).equalsIgnoreCase("true,true,false"));
    }
}
